<?php
/*
  [EWEISHOP] Copyright(C) 2017 Elinkint Inc.
  This is NOT a freeware, use is subject to license terms
   
  PaymentReverse.php 2018-05-24 18:54 cunx $
   
*/

namespace common\library\wechat\payment;

use common\component\wechat\Wechat;
use common\library\wechat\WechatApi;

/**
 * 撤销订单
 * Class PaymentReverse
 * @package common\library\wechat\payment
 * @author cunx
 */
class PaymentReverse extends WechatApi
{
    static $apiType = 'payment';
    static $paymentId = 0;
    /**
     * 通过商户单号撤销订单
     * @param string $outTradeNo    商户单号
     * @return mixed
     * @author cunx
     */
    public static function byOutTradeNumber(string $outTradeNo){
        try{
            $result = self::getInstance()->reverse->byOutTradeNumber($outTradeNo);
        }catch(\Exception $result){}
        return Wechat::apiError($result);
    }

    /**
     * 通过微信支付单号撤销订单
     * @param string $transactionId 微信支付单号
     * @return mixed
     * @author cunx
     */
    public static function byTransactionId(string $transactionId){
        try{
            $result = self::getInstance()->reverse->byTransactionId($transactionId);
        }catch(\Exception $result){}
        return Wechat::apiError($result);
    }
}